@extends('layouts.app')

@section('content')
<div class="content-header">
    <h1>仓库列表</h1>
    <ol class="breadcrumb">
      <li><a href="{{ url('/') }}"><i class="fa fa-dashboard"></i> 首页</a></li>
      <li class="active">仓库列表</li>
    </ol>
  </div>
<div class="content">
<div class="row">
  <div class="col-md-12">
    <div class="panel panel-primary">
      <div class="panel-heading">
        仓库列表
        <a class="pull-right label label-primary" href="{{ url('logs') }}">近期日志</a>
        <a class="pull-right label label-primary" href="{{ url('clear_project_cache') }}">更新列表</a>
        <a class="pull-right label label-primary" href="{{ url('deploy/batch') }}">批量部署</a>
      </div>

      <div class="panel-body">
        <ul class="nav nav-tabs" role="tablist">
          <li role="presentation" class="active"><a href="javascript:void(0);">已配置</a></li>
          <li role="presentation"><a href="javascript:void(0);">未配置</a></li>
        </ul>
        <div class="setting_list">
          <table class="table table-striped table-bordered table-hover" style="border-top: none">
            @foreach ($projects as $project)
            @if (in_array($project['id'], $setting_list))
            <tr>
              <td>
                <a target="_blank" href="{{ $project['web_url'] }}">{{ $project['path_with_namespace'] }}</a>
                                        
                <div class="btn-group pull-right">
                  @if($user->hasRole(['owner']))
                  <a class="btn btn-xs btn-info" style="margin-right: 10px;" href="{{ url('project/show/'.$project['id']) }}">部署配置</a>
                  @endif
                  <a href="{{ url('deploy',[$project['id']]) }}" class="btn btn-warning btn-xs">
                    去部署
                  </a>
                </div>
        
                @if ($project['description'])
                <div class="panel-body">
                  {{ $project['description']}}
                </div>
                @endif
              </td>
            </tr>
            @endif
            @endforeach
          </table>
        </div>
        <div class="setting_list" style="display: none">
          <table class="table table-striped table-bordered table-hover" style="border-top: none">
            @foreach ($projects as $project)
            @if (!in_array($project['id'], $setting_list))
            <tr>
              <td>
                <a target="_blank" href="{{ $project['web_url'] }}">{{ $project['path_with_namespace'] }}</a>
                                    
                <div class="btn-group pull-right">
                  @if($user->hasRole(['owner']))
                  <a class="btn btn-xs btn-info" style="margin-right: 10px;" href="{{ url('project/show/'.$project['id']) }}">部署配置</a>
                  @endif
                  <a href="{{ url('deploy',[$project['id']]) }}" class="btn btn-warning btn-xs">
                    去部署
                  </a>
                </div>
    
                @if ($project['description'])
                <div class="panel-body">
                  {{ $project['description']}}
                </div>
                @endif
              </td>
            </tr>
            @endif
            @endforeach
          </table>
        </div>
      </div>
                
    </div>
  </div>
</div>
  </div>
@endsection

@section('script')
<script>
  $(function () {
    $('.nav-tabs li').click(function () {
      $('li.active').removeClass('active');
      $(this).addClass('active');
      var index = $(this).index();
      $('.setting_list').hide();
      $('.setting_list').eq(index).show();
    });
  })
</script>
@endsection


